package com.zygh.interactiveplatform.task;

import com.alibaba.fastjson.JSONArray;
import com.zygh.interactiveplatform.common.anno.PcLog;
import com.zygh.interactiveplatform.common.constant.SwaggerTagConst;
import com.zygh.interactiveplatform.config.WebSocketServer;
import com.zygh.interactiveplatform.module.entity.vo.MonitorVO;
import com.zygh.interactiveplatform.module.service.CpuService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class CpuTask {
    @Resource
    private CpuService cpuService;
    @Resource
    private WebSocketServer webSocketServer;

    //@Scheduled(cron = "00 00 07 * * ?")
    //@Scheduled(cron = "0/5 * *  * * ? ")
    @PcLog(logType = "1", module = SwaggerTagConst.Admin.MANAGER_CPU_MONITOR, content = "检测服务器CPU状况")
    public void task() throws Exception {
        MonitorVO cpu = cpuService.info();
        String o = JSONArray.toJSON(cpu).toString();
        WebSocketServer.sendInfo(o, "12");

    }



}
